package Test4;
/*学生类
 *学号、姓名、年龄和分数，实现Comparable接口，按照分数倒序排列；*/
public class Student {
    Comparable comparable;
    private int StuNum;
    private String name;
    private int age;
    private int grade;

    public Student() {
    }
    public Student(Comparable comparable, int stuNum, String name, int age, int grade) {
        this.comparable = comparable;
        StuNum = stuNum;
        this.name = name;
        this.age = age;
        this.grade = grade;
    }

    public int getStuNum() {
        return StuNum;
    }
    public void setStuNum(int stuNum) {
        StuNum = stuNum;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public int getGrade() {
        return grade;
    }
    public void setGrade(int grade) {
        this.grade = grade;
    }
    public Comparable getComparable() {
        return comparable;
    }
    public void setComparable(Comparable comparable) {
        this.comparable = comparable;
    }

    public int compareToStu(Student student){
        int a=0;
        int grade1=this.getComparable().compareTo(student);
        if(this.getGrade()>grade1){
            a=-1;
        }else if(this.getGrade()==grade1){
            a=0;
        }else if(this.getGrade()<grade1){
            a=1;
        }
        return a;
    }
}
